﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class ForgotPass : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["user"] != null)
        {
            this.Log_in1.Visible = false;
            this.Log_out1.Visible = true;
        }
        else
        {
            this.Log_in1.Visible = true;
            this.Log_out1.Visible = false;
        }
        //post back
        if (!Page.IsPostBack)
        {
            if (Session["user"] != null)
            {
                this.Log_in1.Visible = false;
                this.Log_out1.Visible = true;
            }
            else
            {
                this.Log_in1.Visible = true;
                this.Log_out1.Visible = false;
            }
        }
        else
        {
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ConnectDB db = new ConnectDB();
        DataSet ds = db.getInfoUser(this.txtUsername.Text, this.txtEmail.Text);
        if (ds == null || ds.Tables[0].Rows.Count == 0)
        {
            this.lblErrorMess.Text = Constant.MESSAGE_ERROR_USER_NOT_EXIST;
            return;
        }
        else
        {
            ProForgotPass fp = new ProForgotPass();
            fp.sentmail(this.txtEmail.Text, this.txtUsername.Text, ds.Tables[0].Rows[0]["password"].ToString());
            //fp.sentmail();
            Response.Redirect("Result.aspx?sendmail=ok");
        }
    }
}
